<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="at" uri="/WEB-INF/util_tag.tld"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title><s:text name="front.hospital.title"></s:text></title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta content="no-cache" http-equiv="Pragma"/>
		<meta content="no-cache" http-equiv="Cache-Control"/>
		<meta content="0" http-equiv="Expires"/>
		<meta name="GENERATOR" content="MSHTML 8.00.6001.18854"/>	
		<link href="<at:url css="frontView.css"/>"  rel="stylesheet" type="text/css" media="screen" />
		<style type="text/css">
			.bha {width: 100%;height: 374px;overflow: hidden;margin:0;font-family:"微软雅黑";}
			.bha1 {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
		</style>
		<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=wFy50EAszGznyPoG7M3pHEUM"></script>
		<script type="text/javascript" src="${rootPath}/Common/Js/jquery.js"></script>
		<script type="text/javascript">
			/**
			 * 返回
			 */
			function goBack(){
				var url="index!hospitalListFrame?flag=return";
				window.location.href=url;
			}
			
			//百度地图API功能
			/*function loadJScript() {
				var script = document.createElement("script");
				script.type = "text/javascript";
				script.src = "http://api.map.baidu.com/api?v=2.0&ak=wFy50EAszGznyPoG7M3pHEUM";
				document.body.appendChild(script);
			}*/
			
			/**
			 * 加载百度地图
			 */
			function searchByStationName() {
				//$("body").addClass("bha");
				//$("html").addClass("bha");
				//loadJScript();
				$("#allmap").addClass("bha");
				$("#r-result").hide();
				var map = new BMap.Map("allmap");
				var addr = '${hospital.addr}';
				var point = new BMap.Point(0,0);
				map.centerAndZoom(point,12);
				map.enableScrollWheelZoom();   //启用滚轮放大缩小，默认禁用
				map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用
				var myGeo = new BMap.Geocoder();
				var str = "<div style='line-height:1.8em;font-size:12px;'><b>名称：</b>"+'${hospital.name}'+"</br><b>地址：</b>"+'${hospital.addr}'+"</br><b>电话：</b>"+'${hospital.tel}'+"<p style='border-top:1px dashed #44aa99'></p>起点：<input type='text' id='origin' value='' style='border:1px solid #aaa;background:none;' />&nbsp;&nbsp;<input type='button' onclick='walk("+'$("#origin").val()'+");' value='步行' style='border:none;background-color: #f1a725;color: white;marin-top:1px;'/>&nbsp;&nbsp;<input type='button' onclick='drive("+'$("#origin").val()'+");' value='驾车' style='border:none;background-color: #1E90FF;color: white;marin-top:1px;'/>&nbsp;&nbsp;<input type='button' onclick='bus("+'$("#origin").val()'+");' value='公交' style='border:none;background-color: #228B22;color: white;marin-top:1px;'/></div>";
				myGeo.getPoint(addr, function(point){
					if (point) {
						map.centerAndZoom(point, 18);
						map.addOverlay(new BMap.Marker(point));
						map.addEventListener("click",function(){ 
							var infoWindow = new BMap.InfoWindow(str);
							map.openInfoWindow(infoWindow,point); 
						}); 
					}
					
				}, "中国");
				
			}
			
			/**
			 * 百度地图步行线路
			 */
			function walk(text){
				if(text==""){
					alert("请输入起点！");
				}else{
					var map = new BMap.Map("allmap");
					var addr = '${hospital.addr}';
					map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
					var walking = new BMap.WalkingRoute(map, {renderOptions:{map: map, autoViewport: true}});
					walking.search(text, addr);
				}
				
			}
			
			/**
			 * 百度地图驾车线路
			 */
			function drive(start){
				if(start==""){
					alert("请输入起点！");
				}else{
					var map = new BMap.Map("allmap");
					//var start = "穿心鼓楼";
					var end = '${hospital.addr}';
					map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
					//三种驾车策略：最少时间，最短距离，避开高速
					var routePolicy = [BMAP_DRIVING_POLICY_LEAST_TIME,BMAP_DRIVING_POLICY_LEAST_DISTANCE,BMAP_DRIVING_POLICY_AVOID_HIGHWAYS];				
					search(start,end,routePolicy[1]); 
					function search(start,end,route){ 
						var driving = new BMap.DrivingRoute(map, {renderOptions:{map: map, autoViewport: true},policy: route});
						driving.search(start,end);
					}
				}
								
			}
			
			/**
			 * 百度地图公交车车线路
			 */
			function bus(text){
				if(text==""){
					alert("请输入起点！");
				}else{
					var map = new BMap.Map("allmap"); 
					$("#r-result").show();
					map.centerAndZoom(new BMap.Point(116.404, 39.915), 10);
					map.enableScrollWheelZoom();
					var end = '${hospital.addr}';
					var transit = new BMap.TransitRoute(map, {renderOptions: {map: map},onSearchComplete: function(result){       
						if (transit.getStatus() == BMAP_STATUS_SUCCESS){
							var firstPlan = result.getPlan(0);
							// 绘制步行线路
							for (var i = 0; i < firstPlan.getNumRoutes(); i++){
								var walk = firstPlan.getRoute(i);
								if (walk.getDistance(false) > 0){
									// 步行线路有可能为0
									map.addOverlay(new BMap.Polyline(walk.getPath(), {lineColor: "green"}));
								}
							}
							// 绘制公交线路
							for (i = 0; i < firstPlan.getNumLines(); i++){
								var line = firstPlan.getLine(i);
								map.addOverlay(new BMap.Polyline(line.getPath()));
							}
							// 输出方案信息
							var s = [];
							for (i = 0; i < result.getNumPlans(); i++){
								s.push((i + 1) + ". " + result.getPlan(i).getDescription());
							}
							document.getElementById("r-result").innerHTML = s.join("<br/>");
						}
					}
					});
					transit.search(text, end);
				}
			}
			
			
		</script>
	</head>
	<body>
		
		<div class="maun_tab">
			<h1>${hospital.name}</h1>
			<div class="yynr_kslb">
				<span>
					<a href="index!sectionList?hospitalId=${hospital.id}">科室设置</a>
				</span> 
				<%--<a href="#" onclick="searchByStationName();">所在位置</a>&nbsp;&nbsp;
				--%><a href="#" onclick="goBack();">返回</a>
			</div>
			<hr/>
			<div class="yynr_img"  id="allmap">
				<s:if test="#request.hospital.imageFile== null" >
					<img src="<at:url image="hospital_default.jpg"/>" width="660" height="374" />
				</s:if>
				<s:else>
					<img src="index!getOrgImg?id=${hospital.id}" width="660" height="374" />
				</s:else>
			</div>
			<div id="r-result" style="line-height:22PX;color: #4169E1;">
			</div>
			<div class="yynr_text">
				<div class="yynr_tt1">
					<ul>
						<li>医院等级：<span>${hospital.hospitalGrade1.name}${hospital.hospitalGrade2.name}</span></li>
						<li>隶属关系：<span>${hospital.subOrdination.name}</span></li>
						<li>机构电话：<span>${hospital.region.areaCode}-${hospital.tel}</span></li>
						<li>医院性质：<span>${hospital.hospitalNature.name}</span></li>
						<li>分类管理类型：<span>${hospital.classifyToManage.name}</span></li>
					</ul>
				</div>
				<p>所属区域：<span>${hospital.region.name }</span></p>
				<p>机构地址：<span><a href="#" onclick="searchByStationName();">${hospital.addr}</a></span></p>
				<span>医院介绍</span><br />
				<p class="yynr_tt">${hospital.intro}</p>
			</div>
		</div>
	</body>
</html>